package com.lxmes.sales.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.sales.domain.NcContractExamine;
import com.lxmes.sales.service.INcContractExamineService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 合同审批列Controller
 * 
 * @author ruoyi
 * @date 2022-11-23
 */
@RestController
@RequestMapping("/sales/examine")
public class NcContractExamineController extends BaseController
{
    @Autowired
    private INcContractExamineService ncContractExamineService;

    /**
     * 查询合同审批列列表
     */
    @PreAuthorize("@ss.hasPermi('sales:examine:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcContractExamine ncContractExamine)
    {
        startPage();
        List<NcContractExamine> list = ncContractExamineService.selectNcContractExamineList(ncContractExamine);
        return getDataTable(list);
    }

    /**
     * 导出合同审批列列表
     */
    @PreAuthorize("@ss.hasPermi('sales:examine:export')")
    @Log(title = "合同审批列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcContractExamine ncContractExamine)
    {
        List<NcContractExamine> list = ncContractExamineService.selectNcContractExamineList(ncContractExamine);
        ExcelUtil<NcContractExamine> util = new ExcelUtil<NcContractExamine>(NcContractExamine.class);
        util.exportExcel(response, list, "合同审批列数据");
    }

    /**
     * 获取合同审批列详细信息
     */
    @PreAuthorize("@ss.hasPermi('sales:examine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ncContractExamineService.selectNcContractExamineById(id));
    }

    /**
     * 新增合同审批列
     */
    @PreAuthorize("@ss.hasPermi('sales:examine:add')")
    @Log(title = "合同审批列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcContractExamine ncContractExamine)
    {
        return toAjax(ncContractExamineService.insertNcContractExamine(ncContractExamine));
    }

    /**
     * 修改合同审批列
     */
    @PreAuthorize("@ss.hasPermi('sales:examine:edit')")
    @Log(title = "合同审批列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcContractExamine ncContractExamine)
    {
        return toAjax(ncContractExamineService.updateNcContractExamine(ncContractExamine));
    }

    /**
     * 删除合同审批列
     */
    @PreAuthorize("@ss.hasPermi('sales:examine:remove')")
    @Log(title = "合同审批列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ncContractExamineService.deleteNcContractExamineByIds(ids));
    }
}
